package com.shwread.android.ui.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.shwread.android.qysw.activity.ReadingBookActivity;
import com.shwread.android.qysw10000243.R;

import org.geometerplus.fbreader.fbreader.ActionCode;


public class PopWindowFontSize
        extends
        ReadingPopWindow
        implements
        OnClickListener
{
	private Button btnFontSizeDown;
	private Button btnFontSizeUp;
	private Button btnLineSpaceMin;
	private Button btnLineSpaceMiddle;
	private Button btnLineSpaceMax;
	
	public static ReadingPopWindow getInstance(Context context) {
		return new PopWindowFontSize(context);
	}

	private PopWindowFontSize(Context context) {
		View contentView = LayoutInflater.from(context).inflate(R.layout.menu_pop_font_size, null);
		init(context, contentView);

	}
	
	@Override
	protected void addListener() {
		btnFontSizeDown.setOnClickListener(this);
		btnFontSizeUp.setOnClickListener(this);
		btnLineSpaceMin.setOnClickListener(this);
		btnLineSpaceMiddle.setOnClickListener(this);
		btnLineSpaceMax.setOnClickListener(this);
		
	}
	
	@Override
	protected void initView(View parentView) {
		btnFontSizeDown = (Button) parentView.findViewById(R.id.menu_pop_font_size_down);
		btnFontSizeUp = (Button) parentView.findViewById(R.id.menu_pop_font_size_up);
		btnLineSpaceMin=(Button)parentView.findViewById(R.id.menu_pop_line_spce_min);
		btnLineSpaceMiddle=(Button)parentView.findViewById(R.id.menu_pop_line_spce_middle);
		btnLineSpaceMax=(Button)parentView.findViewById(R.id.menu_pop_line_spce_max);
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.menu_pop_font_size_down:
				((ReadingBookActivity) context).myFBReaderApp.runAction(ActionCode.DECREASE_FONT);
				break;
			case R.id.menu_pop_font_size_up:
				((ReadingBookActivity) context).myFBReaderApp.runAction(ActionCode.INCREASE_FONT);
				break;
			case R.id.menu_pop_line_spce_min:
				((ReadingBookActivity) context).myFBReaderApp.runAction(ActionCode.SET_LINE_SPACE, 10);
				break;
			case R.id.menu_pop_line_spce_middle:
				((ReadingBookActivity) context).myFBReaderApp.runAction(ActionCode.SET_LINE_SPACE, 12);
				break;
			case R.id.menu_pop_line_spce_max:
				((ReadingBookActivity) context).myFBReaderApp.runAction(ActionCode.SET_LINE_SPACE, 16);
				break;
			default:
				break;
		}
	}
	
}
